package tt.dz.appserver.service.avro.test;

import javax.annotation.Resource;

import org.apache.avro.AvroRemoteException;

import tt.dz.appserver.service.business.UserService;

public class MessageProtocolImpl implements MessageProtocol {

	@Resource
	UserService userService;
	
	@Override
	public Message sendMessage(Message message) throws AvroRemoteException {

		System.out.println("name: " + message.getName());
		System.out.println("type: " + message.getType());
		System.out.println("price: " + message.getPrice());
		System.out.println("valid: " + message.getValid());
		System.out.println("content: "+ new String(message.getContent().array()));
		System.out.print("tags:");
//		for (CharSequence tag : message.getTags()) {
//			System.out.print(" " + tag);
//		}
		userService.getUserById("1");
		System.out.printf("Service:sendMessage方法执行结束\n\n");
		
		return message;
	}

	@Override
	public Message test(Message msg, int code, CharSequence data)
			throws AvroRemoteException {
		System.out.println("data: " + data);
		System.out.println("code: " + code);
		System.out.printf("Service:test方法执行结束\n\n");
		return msg;
	}
}
